<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
	  xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<script language="JavaScript" src="script/upload.js" type="text/javascript">
            
   </script>
</head>
		<ui:composition>
	  	<div align="center">	
			<rich:panel id="majU" headerClass="rich-panel-header-adm" >
				<f:facet name="header">
						<h:outputText value="Modification de l'article #{gestionContenu.contenu.titreContenu}" />
					</f:facet>
				<s:fragment rendered="#{empty gestionContenu.rubriquesDroitAjout()}">
				<h:outputText value="Vous n'avez pas les droits nécessaire pour ajouter un article" />
				</s:fragment>
				<s:fragment rendered="#{not empty gestionContenu.rubriquesDroitAjout()}">
				<h:messages globalOnly="true" styleClass="erreur"/>
				<h:form>
					<h:panelGrid columns="2" columnClasses="top,top">
            <rich:fileUpload fileUploadListener="#{fileUploadBean.listenerLogo}"
                			maxFilesQuantity="#{fileUploadBean.uploadsAvailableLogo}"
                			uploadData="#{file.data}"
                			id="upload"
                			doneLabel="Terminé"
                			transferErrorLabel="Erreur Lors du transfert"
                			addControlLabel="Ajouter un fichier..." 
                			clearAllControlLabel="Supprimer Tout" 
                			clearControlLabel="Supprimer"
							stopEntryControlLabel="Arêter" 
							uploadControlLabel="Joindre"
							immediateUpload="#{fileUploadBean.autoUpload}"
                			acceptedTypes="jpg, gif, png, bmp"
                			noDuplicate="true"
                			allowFlash="true"
                			listHeight="50"  
                       		listWidth="200"
                     		style="height:100;">
                <a4j:support event="onuploadcomplete" reRender="info" />
                
                
            </rich:fileUpload>
            <h:panelGroup id="info">
                <rich:panel bodyClass="info">
                    <f:facet name="header">
                        <h:outputText value="Information du logo joint" />
                    </f:facet>
                   
                    <h:outputText value="Aucun Fichier Joint"
                        rendered="#{gestionContenu.contenu.logo.data==null}" />
                    
                                <a4j:mediaOutput element="img" mimeType="#{gestionContenu.contenu.logo.mime}"
                                    createContent="#{fileUploadBean.paintLogoContenu}"
                                    style="width:100px; height:100px;" cacheable="false"
                                    rendered="#{gestionContenu.contenu.logo.data!=null}">
                                    <f:param value="#{fileUploadBean.timeStamp}" name="time"/>  
                                </a4j:mediaOutput>
                   
                </rich:panel>
                
                <rich:spacer height="3"/>
                <br />
                <a4j:commandButton styleClass="button" action="#{fileUploadBean.clearUploadData}"
                    reRender="info, upload" value="Suppression du logo"
                    rendered="#{gestionContenu.contenu.logo.data!=null or fileUploadBean.uploadsAvailableLogo==0}" />
            </h:panelGroup>
        </h:panelGrid>
        </h:form>
		   <h:form id="ajoutArticle"  reRender="titre,sousTitre,description,texte">
		     <table border="0">
		       <s:validateAll> 
		         <tr>
		           <td>Titre de l'article<br />
		           		<h:inputText id="titre" value="#{gestionContenu.contenu.titreContenu}" required="true" size="66">
		           			<rich:ajaxValidator event="onblur"/>
		           		</h:inputText>
		           		<br/>
		           		<rich:message  errorClass="erreur" for="titre"/>
		           </td>
		           <td>Niveau d'accès<br />
			           <h:selectOneMenu value="#{gestionContenu.contenu.niveauAcces}" required="true">
			  				<s:selectItems id="niveauacces"
			  								value="#{enum.getListNiveauAcces()}" 
			  								var="niveauAcces" 
			  								label="#{niveauAcces.label}"
			  								noSelectionLabel="Choisissez svp"/>
			  								
			  				<s:convertEnum />
						</h:selectOneMenu><br />
						<rich:message  errorClass="erreur" for="niveauacces"/>
    			   </td>
    			   <td>
    			  
					

    			   </td>
		         </tr>
		         
		         <tr>
		           
		           <td>Sous Titre<br />
		           		<h:inputTextarea id="sousTitre" value="#{gestionContenu.contenu.sousTitre}" rows="1" cols="50"/><br />
		           		<rich:message errorClass="erreur" for="sousTitre"/>
		           	</td>
		           	<td>
		           		<h:outputText value="Rubrique Parent" required="true"/><br />
					           <h:selectOneMenu value="#{gestionContenu.contenu.parent}" >
					  			<s:selectItems 	id="parent"
					  							value="#{gestionContenu.rubriquesDroitAjout()}" 
					  							var="ctn" 
					  							label="#{ctn.titreContenu}"
					  							/>
					  							<f:converter converterId="rubriqueConverter"/>		
								</h:selectOneMenu>
								<rich:message errorClass="erreur" for="parent"/>
					</td>
					
		         </tr>
		         <tr>
		          
		           <td>Description<br />
		           		<h:inputTextarea id="description" value="#{gestionContenu.contenu.description}" cols="50"/><br />
		           		<rich:message  errorClass="erreur" for="description"/>
		           </td>
		           <td>Lien Web<br />
		           		<h:inputText value="#{gestionContenu.contenu.lienWeb}"/>
		           </td>
		           
		         </tr>
		         <tr>
		         	<td>Date de création 
						<rich:calendar id="dateC" datePattern="dd/M/yy"  value="#{gestionContenu.contenu.dateCreation}" require="true"/>
						<rich:message errorClass="erreur" for="dateC"/>
					</td>
					
		         </tr>
		         <tr>
		           
		           <td>Texte de l'article
		           		 <rich:editor value="#{gestionContenu.contenu.texte}" theme="advanced" language="fr"  width="600" height="400" style="p"
		           		   plugins="save,paste,cut"  useSeamText="true" id="texte" autoResize="false" label="Texte de l'Article">
          					<f:param name="theme_advanced_toolbar_location" value="top"/>
          					<f:param name="theme_advanced_buttons1" value="bold,italic,underline, cut,copy,paste,pasteword"/>                               
          					<f:param name="theme_advanced_toolbar_align" value="left"/>
						</rich:editor><br />
						<rich:message errorClass="erreur" for="texte"/>
		           </td>
		         </tr>
		       </s:validateAll>
		       <tr>
		       		<td>
		       			 <rich:messages  errorClass="erreur"/>
		     			<h:commandButton type="submit" class="button" value="valider" action="#{gestionContenu.modifierContenu(gestionContenu.contenu)}"/>
		       		</td>
		       		<td>
		       			 <s:button value="retour"  styleClass="button" action="#{menu.afficheGestionArticle()}"/>
		       		</td>
		       </tr>
		     </table>    
        </h:form>
		   
		   </s:fragment>
		   </rich:panel>
		 </div>
	</ui:composition>
</html>